<template>
	<view class="container bg-top">
		<view class="cu-custom">
			<view class="cu-bar fixed bg-top text-white"
				:style="{ height: CustomBar + 'px', paddingTop: StatusBar + 'px' }">
				<view class="action" @tap="backPage"><text class="cuIcon-back text-white"></text></view>
				<view class="content" :style="[{ top: StatusBar + 'px' }]">
					<view class="text-lg text-white">分享佣金</view>
				</view>

				<!-- <view class="right padding-right" :style="[{ top: StatusBar + 'px' }]" @click="handleJump"
						data-url="/pages/distribution/distribution/goods-list/index">
					<view class="text-lg text-white">分佣商品</view>
				</view> -->
			</view>
		</view>
		<!-- 头部 -->
		<view class="relative" :style="[{ top: CustomBar + 'px' }]">
			<view class="padding-lr ">
				<view class=" relative padding-top flex align-center justify-between">
					<view class="flex flex-sub align-center">
						<view class="fu-block-108 round overHidden">
							<fu-image :src="userInfo.head_img || 'https://shengyuanadmin.hnshpjs.com/h5img/images/tab/logo.png'" mode="aspectFill"></fu-image>
						</view>
						<view class="margin-left">
							<view class="text-xl text-white text-blod">{{ userInfo.user_nickname }}</view>
						</view>
					</view>
					<view class="text-theme bg-white radius-100 text-sm padding-lr padding-tb-12" @tap="handleMoney">
						{{i18n['规则说明']}}
					</view>
				</view>
			</view>
			<view class="padding-tb-10 padding-lr-20 margin-top-40 bg-white text-333 margin-lr radius-16 relative">
				<view class="flex padding-tb align-center padding-lr-40 justify-between">
					<view class="flex align-center justify-center flex-direction" @click="handleJump"
						data-url="/pages/wallet/orderMoney-detail/index?active=1">
						<view class="text-sm">{{i18n['今日收益']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ distributionData.today_profit || 0  | formatNumber }}
							<text class="text-df">{{i18n['元']}}</text>
						</view>
					</view>
					<view class="flex align-center justify-center flex-direction" @click="handleJump"
						data-url="/pages/wallet/orderMoney-detail/index?active=2">
						<view class="text-sm">{{i18n['本月收益']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ distributionData.month_profit || 0  | formatNumber }}
							<text class="text-df">{{i18n['元']}}</text>
						</view>
					</view>
					<view class="flex align-center justify-center flex-direction" @click="handleJump"
						data-url="/pages/wallet/orderMoney-detail/index?active=3">
						<view class="text-sm">{{i18n['累计收益']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ distributionData.tprofit || 0  | formatNumber }}
							<text class="text-df">{{i18n['元']}}</text>
						</view>
					</view>
				</view>
				<view class="flex padding-tb align-center padding-lr-40 justify-between">
					<!-- <view class=" flex align-center justify-center flex-direction ">
						<view class="text-sm">{{i18n['总推广人数']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ distributionData.trecommend || 0  | formatNumber }}
							<text class="text-df">{{i18n['人']}}</text>
						</view>
					</view> -->
					<!--  -->
					<view class="flex align-center justify-center flex-direction" @click="handleJump"
						data-url="/pages/distribution/distribution/promotersOrder/index?active=1">
						<view class="text-sm">{{i18n['本月订单']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ distributionData.month_orders || 0  | formatNumber}}
						</view>
					</view>
					<view class="flex align-center justify-center flex-direction" @click="handleJump"
						data-url="/pages/distribution/distribution/promotersOrder/index?active=2">
						<view class="text-sm">{{i18n['累计订单']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ parseFloat(distributionData.torders) || 0  | formatNumber}}
						</view>
					</view>
					<view class=" flex align-center justify-center flex-direction" style="opacity: 0;">
						<view class="text-sm">{{i18n['总推广人数']}}</view>
						<view class="text-prices margin-top-20 fu-fs40 text-bold">
							{{ distributionData.trecommend || 0  | formatNumber }}
							<text class="text-df">{{i18n['人']}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="text-333 margin-lr text-right margin-top" :style="[{ top: StatusBar + 'px' }]"
				@click="handleJump" data-url="/pages/distribution/distribution/goods-list/index">
				<view class="text-lg">分佣商品列表<text class="lg cuIcon-right margin-left-xs"></text></view>
			</view> -->
		</view>
		<!-- 规则说明 -->
		<fu-popup ref="coupon" mode="center" width="550rpx" height="700rpx" border-radius="8" :mask-close-able="true"
			v-model="couponModel" @close="handleClose">
			<view class="rule-box bg-white">
				<view
					class="rule-box-title text-center height-100 line-height-100 text-333 text-bold text-lg solid-bottom">
					{{i18n['分销规则']}}
				</view>
				<scroll-view class="rule-box-content text-666 padding-20" scroll-y>
					<jyf-parser :html="rulers.content"></jyf-parser>
				</scroll-view>
				<view class=" text-center solid-top line-height-100" @click="handleClose">
					{{i18n['关闭']}}
				</view>
			</view>
		</fu-popup>
		<!-- 网络监测 -->
		<fu-notwork></fu-notwork>
	</view>
</template>
<script>
	// 引入混入数据加载 js
	// import pagingList from '@/common/mixin/paging_list.js';
	export default {
		// mixins: [pagingList], //混入
		data() {
			return {
				rulers: {}, //规则说明
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				bgColor: this.$store.state.themeColor,
				userInfo: {},
				distributionData: {}, //数据统计
				dataContetn: {},
				isShowLoading: false,
				minixPagingListsApi: global.apiUrls.postDistributionPersonList, //混入获取列表接口名
				// allowOnloadGetList: false, //是否允许onlaod加载数据
				pageingListApiMethod: 'post', //接口类型属于get
				page: 1,
				tabCurrentIndex: 0, //顶部导航 选择的第几个
				navList: [{
					state: 0,
					text: global.i18n['全部人员'],
					type: 0,
					number: 0
				}], //冻结顶部导航
				couponModel: false
			};
		},
		onShow() {
			this.userInfo = global.userInfo || {};
			if (!global.token) {
				this.back();
			} else {
				this.getIndeContent();
			}
		},
		methods: {
			/**
			 * @description 混入传参钩子函数
			 * @param type 获取数据类型 type 1为收藏列表 3为浏览历史
			 */
			// pagingListPostData() {
			// 	return {
			// 		type: this.tabCurrentIndex, //1：获取直推列表，2：获取间推，不传获取全部
			// 		sort: 'desc',
			// 		page: this.page,
			// 	};
			// },
			backPage() {
				uni.navigateBack()
			},
			// 切换直推间推
			tabClick(index) {
				this.$util.debounce(() => {
					this.tabCurrentIndex = index;
					this.type = this.navList[index].type;
					uni.pageScrollTo({
						scrollTop: 0,
						duration: 0
					});
					// this.pagingListToggle()
				}, 200)
			},
			// 主数据列表
			getIndeContent() {
				this.$api
					.post(global.apiUrls.postDistributionIndex, {})
					.then(res => {
						if (res.data.code == 1) {
							this.distributionData = res.data.data;
							// 推广人数
							this.navList[0].number = res.data.data.trecommend;
							this.navList[1].number = res.data.data.recommend_count1;
							this.navList[2].number = res.data.data.recommend_count2;
						} else {
							this.$message.info(res.data.msg);
						}
					})
					.catch(err => {
						console.log(err);
					});
			},

			// 首页数据
			handleMoney() {
				this.$api
					.post(global.apiUrls.postDistributionRuler, {
						user_id: global.userInfo.id || 0,
						category_id: 9
					})
					.then(res => {
						if (res.data.code == 1) {
							this.rulers = res.data.data;
						} else {
							this.$message.info(res.data.msg);
						}
					})
					.catch(err => {
						console.log(err);
					});

				this.couponModel = true;
			},
			handleClose() {
				this.couponModel = false;
			}
		}
	};
</script>
<style lang="scss" scoped>
	.bg-top {
		background: url($IMG_BASE_URL+'distribution/distri-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 492rpx;
	}

	.container {
		.active::after {
			content: '';
			position: absolute;
			width: 40rpx;
			height: 4rpx;
			bottom: 0rpx;
			background-color: $theme;
			left: 0;
			right: 0;
			margin: auto;
			border-radius: 6rpx;
		}

	}

	.bottom-action {
		position: fixed;
		left: 32rpx;
		right: 32rpx;
		bottom: 32rpx;
		height: 80rpx;
		line-height: 80rpx;
		bottom: calc(32rpx + constant(safe-area-inset-bottom));
		bottom: calc(32rpx + env(safe-area-inset-bottom));
	}

	// 规则弹窗
	.rule-box {
		width: 100%;
		height: 100%;

		.rule-box-content {
			height: calc(100% - 200rpx);
		}
	}

	.solid-right {
		border-right: 1rpx solid rgba(0, 0, 0, 0.2);
	}

	.status-badge {
		border: 1px solid $theme;

	}
</style>
